home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Tutorial / Cookbook / 10.matrix / notes < prev    next >
Text File  |  1995-06-12  |  2KB  |  57 lines

  1. Objective:
  2.    To learn to receive event messages from a matrix object and tell
  3.    which element within a matrix is sending a message.
  4. Terms:
  5.    Tag: an integer associated with an element of a matrix object.
  6.    
  7. Discussion:
  8.  
  9. We will use almost the same procedure as we have done before but
  10. we will use the selectedRow, selectedCol and selectedTag methods
  11. to get the position of the matrix button that has been selected.
  12.    
  13. Method:
  14.  
  15. Create a subclass of "Object" and give it two actions: "myAction:"
  16. and "myAction2:".  Unparse.  Then create an instance of it using the 
  17. "Objects/NewCustom Objects" meun selection. Drag a radio button
  18. on to the screen and use the ALT/DRAG on one of the corners to
  19. create a matrix of Radio buttons with about 5 rows and three columns.
  20. Do the same with a button.  You will now have a matrix of radio buttons
  21. and a matrix of regular bottons.  Connect the matricies to the myObject1
  22. by CONTROL/DRAGING a line from the matrix objects to "Objects" window
  23. and connect it to the myObject1 and use the myAction1: method for one
  24. matrix and the myAction2: method for the other matrix.  Save the
  25. nib file and change the action methods in MyObject.m to be the following:
  26.  
  27. - myAction:sender
  28. {
  29.     printf("Row = %d  ", [sender selectedRow]);
  30.     printf("Col = %d  ", [sender selectedCol]);
  31.     printf("Tag = %d\n", [sender selectedTag]);
  32.     return self;
  33. }
  34.  
  35. - myAction2:sender
  36. {
  37.     printf("Row = %d  ", [sender selectedRow]);
  38.     printf("Col = %d  ", [sender selectedCol]);
  39.     printf("Tag = %d\n", [sender selectedTag]);
  40.     return self;
  41. }
  42.  
  43. Save ant type "make".  Note that by default, the Tag for the radio
  44. buttons is 0 or 1 for the second radio button only.  To have a unique
  45. tag for each radio button selection use the inspector for the radio button
  46. matrix and check the box that says "Cell Tags = Positions".
  47.  
  48. Other Suggestions:
  49.  
  50. Try changing some of the other options in the matrix inspector.
  51.    
  52. Summary:
  53.  
  54. You now know how to integrate a matrix of objects into your programs
  55. for interfaces that require selecting one of many options.
  56.  
  57.